package com.lzw.controller.student;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lzw.pojo.Announcement;
import com.lzw.service.student.SAS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.List;

@CrossOrigin(origins = "http://localhost:7070")
@RestController
@RequestMapping("/SA")
public class SAC {

    @Autowired
    private SAS sas;

    @GetMapping("/list")
    public PageInfo<Announcement> list(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate dataPosted) {
        PageHelper.startPage(pageNum, pageSize);
        List<Announcement> list = sas.list(pageNum, pageSize, dataPosted);
        return new PageInfo<>(list);
    }
}
